package routes

import (
	v1 "ginblog/api/v1"
	"ginblog/utils"
	"github.com/gin-gonic/gin"
)

func InitRouter() {
	gin.SetMode(utils.App_Mode)
	r := gin.Default()

	router := r.Group("api/v1")
	{
		// 用户模块的路由接口
		router.POST("user/add", v1.AddUser)
		router.GET("users", v1.GetUsers)
		router.PUT("user/:id", v1.EditUser)
		router.DELETE("user/:id", v1.DeleteUser)
		router.POST("user/checker", v1.UserExists)
		router.POST("user/login", v1.Login)
		//router.POST("user/changepassword", v1.ChangePassword)
		// 分类模块的路由接口
		router.POST("category/add", v1.AddCategory)
		router.GET("categorylist", v1.GetCategoryList)
		router.PUT("category/:id", v1.EditCategory)
		router.DELETE("category/:id", v1.DeleteCategory)
		// 文章模块的路由接口
		router.POST("article/add", v1.AddArticle)
		router.GET("articlelist", v1.GetArticleList)
		router.PUT("article/:id", v1.EditArticle)
		router.DELETE("article/:id", v1.DeleteArticle)
		router.POST("article/GetArticleById", v1.GetArticleInfo)
	}

	err := r.Run(utils.Http_Port)
	if err != nil {
		return
	}
}
